﻿using DotNetExtensions.Core.Restful;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CoreWebSimple.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class FileUploadController : ControllerBase
    {
        [HttpGet]
        public ApiResult<PageResult<PersonModel>> Get()
        {
            try
            {
                PageResult<PersonModel> pageResult = new PageResult<PersonModel>();
                pageResult.Total = 100;
                pageResult.PageIndex = 1;
                pageResult.PageSize = 20;
                pageResult.Data = new List<PersonModel> {
                    new PersonModel(){ Age = 10, Id = 1, Name = "Jack ma"}
                };
                throw new Exception("hhh");
                // return ApiResult.OK(pageResult);
            }
            catch
            {
                return ApiResult.Failed<PageResult<PersonModel>>("hhh", null);
            }
        }

        [HttpGet]
        public ApiResult<string> Error()
        {
            throw new Exception("没有实现这个方法");
        }
    }
}
